package com.example.backend.dto;

import com.example.backend.domain.enums.TicketPriority;
import com.example.backend.domain.enums.TicketStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.Instant;

/**
 * 工单列表DTO - 用于列表页面显示
 * 只包含必要字段，减少数据传输量和序列化开销
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TicketListDTO {
    
    /**
     * 工单ID
     */
    private Long id;
    
    /**
     * 工单编号
     */
    private String ticketNumber;
    
    /**
     * 工单标题
     */
    private String title;
    
    /**
     * 工单状态
     */
    private TicketStatus status;
    
    /**
     * 优先级
     */
    private TicketPriority priority;
    
    /**
     * 客户ID
     */
    private Long customerId;
    
    /**
     * 客户名称
     */
    private String customerName;
    
    /**
     * 分配人ID
     */
    private Long assignedToId;
    
    /**
     * 分配人名称
     */
    private String assignedToName;
    
    /**
     * 分类ID
     */
    private Long categoryId;
    
    /**
     * 分类名称
     */
    private String categoryName;
    
    /**
     * 创建时间
     */
    private Instant createdAt;
    
    /**
     * 更新时间
     */
    private Instant updatedAt;
    
    /**
     * 到期时间
     */
    private Instant dueDate;
    
    /**
     * 是否已升级
     */
    private Boolean isEscalated;
    
    /**
     * 满意度评分
     */
    private Integer satisfactionScore;
    
    /**
     * JPQL构造函数投影构造器
     * 用于Repository查询中的new操作符
     */
    public TicketListDTO(
            Long id,
            String ticketNumber,
            String title,
            TicketStatus status,
            TicketPriority priority,
            Long customerId,
            String customerName,
            Long assignedToId,
            String assignedToName,
            Long categoryId,
            String categoryName,
            Instant createdAt,
            Instant updatedAt,
            Instant dueDate,
            Boolean isEscalated
    ) {
        this.id = id;
        this.ticketNumber = ticketNumber;
        this.title = title;
        this.status = status;
        this.priority = priority;
        this.customerId = customerId;
        this.customerName = customerName;
        this.assignedToId = assignedToId;
        this.assignedToName = assignedToName;
        this.categoryId = categoryId;
        this.categoryName = categoryName;
        this.createdAt = createdAt;
        this.updatedAt = updatedAt;
        this.dueDate = dueDate;
        this.isEscalated = isEscalated;
    }
}

